<template>
  <div class="nav-menu bg-w">
    <a-menu v-model="current" mode="horizontal" @click="handleClick">
      <a-menu-item key="dynic">
        <router-link :to="{ name: 'dynic', params: {id} }">动态</router-link></a-menu-item
      >
      <a-menu-item key="user-article"
        ><router-link :to="{ name: 'user-article', params: {id: id} }"
          >作者文章</router-link
        ></a-menu-item
      >
      <a-menu-item key="article-agree"
        ><router-link :to="{ name: 'agree', params: {id: id} }"
          >赞的文章</router-link
        ></a-menu-item
      >
      <a-menu-item key="userFocus">
        <router-link :to="{name: 'userFocus', params: {id: id}}">关注</router-link>
      </a-menu-item>
      <a-menu-item key="boil"
        ><router-link :to="{ name: 'boil', params: {id: id} }">沸点</router-link></a-menu-item
      >
    </a-menu>
  </div>
</template>

<script>
import { setSessionStorage, getSessionStorage, parse } from "@/utils/utils";
import {mapState} from 'vuex';
export default {
  name: "NavMenu",
  data() {
    const path = getSessionStorage("keyPath") || 'dynic';
    const cid = getSessionStorage('cid');
    let isUser;
    if (cid) {
      isUser = parse(cid).isUser;
    }
    return {
      current: [path],
      id: this.$store.state.uId,
      isUser
    };
  },
  methods: {
    // 存入session
    handleClick({ keyPath }) {
      setSessionStorage("keyPath", keyPath[0]);
    },
  },
};
</script>
